window.onload = function () {

    function handleScroll(e) {
        var html = document.getElementsByTagName('html')[0]
        var d2dom = document.getElementById('d2')
        var d3dom = document.getElementById('d3')
        var d4dom = document.getElementById('d4')
        var d5dom = document.getElementById('d5')
        var d6dom = document.getElementById('d6')
        var d7dom = document.getElementById('d7')
        var d8dom = document.getElementById('d8')
        var d9dom = document.getElementById('d9')

        var d1 = document.getElementById('d1').offsetTop
        var d2 = document.getElementById('d2').offsetTop
        var d3 = document.getElementById('d3').offsetTop
        var d4 = document.getElementById('d4').offsetTop
        var d5 = document.getElementById('d5').offsetTop
        var d6 = document.getElementById('d6').offsetTop
        var d7 = document.getElementById('d7').offsetTop
        var d8 = document.getElementById('d8').offsetTop
        var d9 = document.getElementById('d9').offsetTop
        var e = e || window.event;
        if (e.wheelDelta) {
            if (e.wheelDelta < 0) {
                if ((html.scrollTop == d1 + 300 || html.scrollTop > d1 + 300) && html.scrollTop < d2) {
                    paly(d2,d2dom)
                    remove($(d2dom))
                }
                if ((html.scrollTop == d2 + 300 || html.scrollTop > d2 + 300) && html.scrollTop < d3) {
                    paly(d3,d3dom)
                    remove($(d3dom))
                }
                if ((html.scrollTop == d3 + 300 || html.scrollTop > d3 + 300) && html.scrollTop < d4) {
                    paly(d4,d4dom)
                    remove($(d4dom))
                }
                if ((html.scrollTop == d4 + 1500 || html.scrollTop > d4 + 1500) && html.scrollTop < d5) {
                    paly(d5,d5dom)
                    remove($(d5dom))
                }
                if ((html.scrollTop == d5 + 300 || html.scrollTop > d5 + 300) && html.scrollTop < d6) {
                    paly(d6,d6dom)
                    remove($(d6dom))
                }
                if ((html.scrollTop == d6 + 100 || html.scrollTop > d6 + 100) && html.scrollTop < d7) {
                    paly(d7,d7dom)
                    remove($(d7dom))
                }
                if ((html.scrollTop == d7 + 100 || html.scrollTop > d7 + 100) && html.scrollTop < d8) {
                    paly(d8,d8dom)
                    remove($(d8dom))
                }
                if ((html.scrollTop == d8 + 100 || html.scrollTop > d8 + 100) && html.scrollTop < d9) {
                    paly(d9,d9dom)
                    remove($(d9dom))
                }
            }
        }

    }
    function action() {
        return new handleScroll()
    }
    function remove(dom) {
        $(dom).each(function () {
            try{
                $(dom)[0].addEventListener("animationend", function () {
                    $(dom).css("animation", "");
                });
            }catch(e){
                console.log(e);
            }
        });
    }
    function paly(d,dom){
        $("body,html").animate({
            scrollTop: d + 'px'
        }, 300);
        dom.style.animation = 'textmove 3s 1'
        dom.style.animation = 'imagemove 3s 1'
    }
    try {
        window.addEventListener("wheel", action) || window.addEventListener("mousewheel", action) || window.addEventListener("DOMMouseScroll", action);
    } catch (e) {
        window.attachEvent("mousewheel", action);
    }

}